package com.hgq.tenadmin.md.activity.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hgq.tenadmin.md.activity.dao.MdActivityDao;
import com.hgq.tenadmin.md.activity.param.FindParam;
import com.hgq.tenadmin.md.activity.service.MdActivityService;
import com.hgq.tencommon.entity.md.activity.MdActivity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class MdActivityServiceImpl implements MdActivityService {
    @Resource
    private MdActivityDao mdActivityDao;


    @Override
    public PageInfo<MdActivity> findAllActivity(FindParam findParam,int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MdActivity> mdActivities = mdActivityDao.selectAllActivity(findParam.getActivityName(),
                findParam.getStartTime(), findParam.getEndTime(), findParam.getType(), findParam.getCity(), findParam.getState());
        PageInfo<MdActivity> mdActivityPageInfo = new PageInfo<>(mdActivities);

        return mdActivityPageInfo;
    }

    @Override
    public void saveOneActivity(MdActivity mdActivity) {
        mdActivityDao.insertOneActivity(mdActivity);
    }

    @Override
    public void updateOneActivity(MdActivity mdActivity) {
        mdActivityDao.updateOneActivity(mdActivity);
    }

    @Override
    public void removeOneActivity(Integer aid) {
        mdActivityDao.deleteOneActivity(aid);
    }
}
